factor keyhotee code into a library to enable unit testing