ThreadKeyGeneratorImpl refactoring + tests