I didn't look at the code but am fully in agreement with your approach. While it is not a 'pure' way to do unit tests, execution speed 10x improvement is much more valuable than purity in this case, and the only likely consequence is that breaking one test might cause later ones to break too; that's not the end of the world if it is detected quickly (ie people run full set of unit tests regularly - a lot more likely to happen if they don't take half an hour).
When I asked Tim about it too, he reluctantly agreed; he did complain that the gradebook should have been developed in such a way that it was separated from the database (i.e. you could do unit tests without requiring db setup at all, entirely in RAM) but it is a bit late for that!
One thing - in current HEAD the unit tests (for the whole system) now finally give a 'green' result . Please don't commit any changes to unit tests unless the unit tests (for whole system) still run green, i.e. I don't think you should commit this until you fix it.
I have filed
MDLSITE-1120 requesting that the nightly unit test run is made to work again, this should enable us to see daily whether unit tests are still working.
That's all my opinion. Although I have recently led others here to make the unit tests run and pass for moodle 2 launch hopefully, this is probably a one time effort and I'm not the maintainer of unit tests in moodle! So I don't have any say if you want to do whatever.