Add unit tests for KeyCommand. Fix the KeyCommand.