a bunch of test updates

These changes include mostly test updates to verify the new API, but also a few bug fixes in the implementation uncovered while fixing the tests. Note that we still don't have all of the tests running.