I'll try to give you a simple idea of all this sentences)
Somebody told you to do something - this action was the first, so it was previously thats why here we use past perfect. (I had been told to do)
If you use - "I did" in the 1st part of the sentence you confirm that you did something what you had been told to do. If you use "I was doing" you mean particular period of time during which you were doing something.
those sentnces grammatically uncorrected because in the 1st part of the sentence you use past time - action you did in the past, but in the second part of the sentence you should use past perfect because that action was before.