Added much needed unit tests and refactored the code a bit