Take another look at the sentence:
The comma between test and he is completely correct. Even when he has a test is a subordinate clause, so it cannot stand alone. His head hits the desk by 8:05 is a main clause. When a subordinate clause introduces a main clause, you need to separate them with a comma.