You seem to have confused a lot of different thigs here.
Night time tests are allowed, but only in exceptional circumstances.
The Bahrain 'raid' had nothing to do with testing.
WRT pre-race tests, the details have already been given: first thing in the morning and before the stage start.
Nope, not confused, just unsure of whether the night time tests actually occur, and if so to what extent. As you say, exceptional circumstances, so I guess the main deterrent effect there is that it could happen. I know the Bahrain situation was completely different, but it's one of the only recent reports I recall of anything happening in the evening. But yes, obviously not a testing protocol and thus not a good example by me!
Regarding the timing of tests, I guess my main curiosity regarding the testing before the stage is how controlled it is and how immediately before the stage it is. I'm thinking of the pre-race staging area and if they pull racers out to test them and if that delays the start. If there's a risk you'll get tested right at the start line, then that is an interesting deterrent.
At some past races I have been to there's quite the consumption of small bottled beverages being consumed (often in a unmarked bottle), or asthma inhalers being puffed on repeatedly. Much of that was related to stimulant overkill, but the interesting thing was how much activity was obviously going on, so I wonder about pre-race prep happening more behind the scenes. You would need to be
really bold and well resourced to do anything really dodgy pre-race.