Added documentation and rearranged the tests a bit.