refactor module and unit tests