you not only failed because of excessive NOx, but also because your Check Engine Light was on (error detected).
first scan the ECU with OBD scanner or jumper the terminals and read the code(s).
http://www.troublecodes.net/Toyota
second, look into the EGR system, this is what helps reducing NOx if working correctly. other than that your catalytic converter(s) maybe on the way out.
also, next time you attempt testing for smog, drive the car for a minimum of 30 mins on highways before going to inspection station. if systems were not fully warmed up then the 3-way catalytic converter might have been working inefficiently.
changing oil also helps reduce emissions as well as running a tank of gas with a cleaning additive (e.g. Chevron Techron or CRC Emission Formula cleaner), but remember to drive it almost dry and then refill with fresh fuel BEFORE going to inspection station (with a fully warmed up car)