added 10 unit tests and broke up some functions to make it easier to test