util: Fix memory leaks in unit test.