added tests, generator refactoring