Cleaned up some code.
Added documentation to tests.