Added a couple more unit tests and did some refactoring/documentation.