Tests: Cleanup and cover all the main cases
Added lots of more tests to cover all the cases of the public API that we were missing as per the current coverage, improving it quite a lot (+9%!).
Fixed some issues I found while testing.
The first commits of this branch are actually the ones included in !42 (closed) (on which this is based, so ignore them in this review), while this makes !40 (merged) quite a lot more useful.
Edited by Marco Trevisan