fix key handling, all tests now pass