A random sample of each make and model of car should be periodically put through far more stringent testing than normal, in an effort to catch this kind of thing. Allowing this cheat to go undetected for so long speaks to the failure of the testing regime.
Let's not pretend that there aren't problems there too.
In reality, it is very helpful to have a carefully controlled, consistent test so that comparisons between vehicles are apples to apples. Variances in the real world will be argued as inevitable, and very quickly you'll find the industry converges on how likely it is that a give variance is "acceptable/plausible", and then you'll have engineers designing for that variance....