Fix more memory leaks in tests