Fixed return values; tester now responsible for freeing keys