more tests and refactoring for hw