Fix test failures

For once, each commit corresponds to a logical patch.