Issues like what was found and fixed in T175898 should be caught by unit testing; ideally, we should have a unit test that should run checks on some fake data and compare the results with the expected results.
It will be a bit hard though, because of the "fake data" part, and due to the fact that CU functions only accept DB tables as the input and cannot be run on, say, an arbitrary data source (otherwise we could package with the CU unit tests a sqlite DB with some fake data in it). Do we have other unit tests that use alternative data sources?