token generator, tests and refactoring