fix memleak in tests