Fix for issue #8023

Can someone code review.
you don't even need to do this in a function, just put it at the end of the module and directly update TestCase. (pls put a comment before though explaining what this is doing).