Fix tests

This is to fix a number of test failures. It'd be great if someone could review those commits just to be sure I didn't do anything stupid. Thanks!