Test coverage improvement

Added a whole bunch of tests, fixed some docs and edge cases.
Could you add a weighted test please?