Ford Repair: clearing codes, major attitude, code scanner


Question
 I had a PO141 code that pointed to a downstream O2 sensor, I found that sensor was loose. I tightened it and cleared the check engine light by disconnecting the battery.
 When I took it to get reinspected they said the only way to clear the computer was to drive it 100+ miles. Autozone (I know, I know) said they could clear it but when they checked they said there were not any codes to clear.
 When I took it back to the inspection station the person the checked it (with a major attitude) failed it again saying the codes were still present but did not give me any new paperwork saying it failed, just my older paperwork.
so... a) how can I be sure to clear the codes and how many miles does it really take??
     b) Is the guy at the inspection station lying?
Most important is for me to be certian the codes are clear so I can have someone else inspect it tomorrow.
  Thank you in advance

Answer
Mark-

  The only way to truely clear a code is with a code scanner (probably one better than the gang at Autozone has) but unhooking the battery seems to work almost as well so long as the problem is actually fixed.  Just remember that the battery has to be completely unhooked for about 15-20 minutes with the key turned to the "accessory on" position in the ignition.  That will drain whatever electricity in left in the ECU and force it ro "relearn" the car after it's hooked back up and started.  And no...there's no minimum mileage to clear a code.  That's so ridiculous I don't even know where to start.  Is the inspection guy lying?  It's possible.  I can't say I've ever met the man and I'm hesitant to call someone a liar, so let's just say it's more likely that he's just an idiot.  State inspection stations are rarely employed by people who really know cars so he's probably just working off of some kind of manual or check list.  Hope this helps.

Steve