Refactored code to make easier to unit-test and also added first new unit
test using this refactor. Added a script for easier running of unit tests,
and will be adding new unit tests quickly/shortly