Refactor tests
Refactor main module