[PATCH] tests: Fix some memory leaks in testcases.