Fixed double free'ing in tests