generator - refactoring + tests round 1
generator - refactoring + tests round 1