fixed tests, refactored some generated code