tests: fix memory leaks.