Add tests and Refactor modules and controller