More tests, and some small fixes