Fixes resource leaks in unit-tests.