Improved clean-up for test cases.