move key generator to its own class and add test