Fix unit test failures

And a few other random cleanup things