Fixed memory leak.
Fixed test.