So how does one test O2 sensor?
\D
Once the engine is warmed up, unplug it. It will set the O2 sensor code (pretty much guaranteed) and should turn on the CEL light.
But if the idle settles down, the ECM would seem to be fighting with what the O2 sensor is feeding it.
If that's the case, I would be inclined to replace it. No guarantees, but what else ya' gonna do?
I
don't think it's the coils or associated pieces.
Edit - If you've got a scan tool, it should show ~.445 volts (DC) when the O2 is cold. (That value is "plugged in" to the PCM, and is used as a default, until the O2 warms up and starts responding to actual exhaust readings.)
Once it warms up, it should bounce back and forth between .1 and .8 volts (or thereabouts.) It should spend about half the time on either side of .445 volts.
If it parks on one side or the other, it thinks it's seeing a continuous lean or rich condition. Towards .8 is rich. Towards .1 is lean. If you are accelerating or decelerating, a temporarily full rich or full lean condition is normal.
The O2 CAN lie. At one point, the one on my 4.9 indicated full lean (very low voltage.) The PCM compensated by dumping in as much fuel as it could. Failed a smog test horribly. Also killed my catalyst. My gas mileage was also crap.