A, B, C and E can all be read as grammatical, using standard English. D is the most questionable combination, but it is not impossible if you resort to some unique, idiosyncratic, or nonstandard English. Thus this test question, like many that we see here, is terrible.
As for the would in E, it talks about the future from the the point of view of the past.
Let's say 10 o'clock means 10 AM. And that you paid a visit at noon (12 PM). If the time is now after the visit is over, say 8 PM, you could say the sentence as if it were some time between 10 AM and 12 PM, for example as if were 11 AM. It is not really 11 AM, it is 8 PM, but you are looking back on all the events and speaking from the point in time of 11 AM.
By ten o'clock he had repaired the engine and (as of the point in time of 11 AM) he would start to paint the garage when I paid a visit to him (at noon).
In reality, all the events, including paid a visit have been completed (are in the past). But the sentence is spoken as if the event pay a visit has not yet happened: it's still in the future as of 11 AM.
To make this clearer, let's do the opposite of backshift and "frontshift" all these verbs:
By ten o'clock he repaired the engine and he will start to paint the garage when I pay a visit to him.
I hope it's clear that this is grammatical. It talks about one completed event (repaired the engine) and one future event (will start to paint the garage); the future event will happen when something else happens. This something else (when I pay a visit) is still in the future. So the time point of this sentence is after the completed event but before the future event. It is the same for E, except that all the events are part of the past, and you are speaking as if pay a visit is still in the future.