fixed tests, refactored some generated code
Merge pull request #260 from noahsug/master

fixed tests, refactored some generated code