CROWDCON-4 Finished unit tests and refactoring