some test fixes, refactoring and added HHGen