Fix memory leaks in the test example.