tests: Fix memory leak