There isn't anything legally wrong with designing a software system that passes the test. The laws are written that the vehicle must meet a certain criteria. Even if the car uses things like steering input to sense it's on the dynamometer being tested and it adjusts itself accordingly that still isn't against the law. The US Environmental Protection Agency was very careful to use the words "Defeat Device" with regards to VW which means that when the vehicles were not being tested some emission control systems were being shut down and that unfortunately is a big no no. Defeat device is a legacy going all the way back to the earliest days of catalytic converters where people would take them out or bypass them. Of course some enterprising individuals came up with very slick converter replacement pipes. the USEPA then passed rules against installing "defeat devices". After that all the bypass pipes were re-branded "test pipes".
BMW may have failed the same "real world" test performed by the university that discovered the problem with VW but unless they too have set the software up to disable one or more systems they are probably in the clear.