fix leak in test cases