A collection of fixes to make the test suite pass again, plus more test coverage.