tests: Fix some memory leaks