Merge "Detect and fix resource leakages in tests"