Write unittests and refactor params