More tests, docs and some fixes