Test coverage improvement

Added a whole bunch of tests, fixed some docs and edge cases.
Good catch.