test: fix memory leak