Toyota Repair: failed emissions test, throttle position sensor, toyota sr5 pickup


Question
I own a 1989 Toyota SR5 pickup with a 22RE engine(California model)that failed the emissions test on the "functional check" portion of the test.I passed the "visual inspection" and the "emissions test"(at levels well below 1/2 the max allowed emissions levels for HC,CO,and NO).The failing factor was a "MECH PROB" with the ignition timing(I was told by the test tech that it was aprox. 25 deg BTDC.he also told me that the problem was not with the distributor but was probably due to a malfunctioning sensor,ie:an electrical problem.As this was at a test only smog test facility ,he wouldn't have any reason to mislead me).I haven't had any check engine lights come on and there were no error codes when I checked.The truck runs well(except for a high cold idle which from my research is par for the course). My question is how can the timing be so far out and have it still pass the emissions test with flying colors? And what sensor could put the timing so far out? I've checked  around and this one has gotten me stumped and I need to get my truck smoged asap.Thank you for any help you can give me.

Answer
The engine timing is set by the position of the distributor so the initial timing has to be checked with the diagnostic connector jumped with a wire between terminals TE1and E1, I don't know if the smog tech did this but if not the timing will check as too far andvanced, there are some other factors to consider, a malfunctioning throttle position sensor or a bad knock sensor, both have an input to the engine timing but in most cases these will turn the check engine light on, the knock sensor is seldom the problem, it's more likely that the distributor is off, this can be checked with the above procedure, if the timing can not be correctly set it may be that the timing chain is worn or the crank/cam timing is off, to verify that the valve cover has to be removed. Has any major repair been done to the engine recently and if so, what?