Fixing some memory leaks in the test suite