tests and some generator refactoring