Improve coverage

* Some tests fixed and some new added.
* Optional parameters that can actually never be omitted became mandatory.
* Exceptions that check consistency inside modules replaced with asserts.
Not sure if it's a good idea to require assert out of the unit tests. By doing that we would add a dependency if someone wants to run the library in the browser.