added memory cleanup to tests