Added tests, refactored code, linted