More tests, and some small API changes.