Feature/unit tests

* Changes to make things easier to test. (moved out of rakefile into library)
* Wrote tests that cover most of stuff in rake file.