Tests: was freeing memory too early