...due to the actions of some lone shark at VW. ????
In the automotive industry, EVERYTHING is specified, designed, signed off by lots of senior managements, both before and during implementation. During, and after, implementation, every functionality is rigorously tested at several different levels (unit tests, ..., system tests). After all, a defect found after manufacturing, even if not dangerous, is expensive to fix.
There are lots of ECUs ("electronic control units") in a car, each performing a single function. partly for reliability, partly out of common sense. They communicate over CAN busses.
In the current scenario, VW's engine control ECU must be receiving lots of signals from other ECUs (e.g. a steering ECU) for which it has no legitimate need. Rather, it needs those signals for detecting the car's being tested. It is probable that some of these signals are properly private to a single ECU and wouldn't otherwise be broadcast on a CAN bus.
There will be several ECU development groups which will have to have co-operated over these illegitimate signals, lots of test engineers will have tested them. They will all be documented in design documents. The development of the cheating function will have consumed several man years of engineers' time.
This was NOT "due to the actions of some lone shark". VW's senior management could not possibly have been unaware of this development. However I expect, as is usual in these circumstances, management will deny all knowledge, get away with it, and manage to scapegoat a few unfortunate engineers. VW's ex-chief Winterkorn has already got away with a multi-million euro payoff.