Fix memory leak test in valgrind --tool=memcheck --leak-check=full