Test coverage improvement

Added a whole bunch of tests, fixed some docs and edge cases.
The test was "if there are weights, the length should be the same as the data". However, the nil check is above, so it's okay to remove it here.