Added a bunch of unit tests and updated some documentation