test: Fix memory leak