Test fixes

These changes were against master, so you're seeing a lot of other commits/changes which are unrelated.

Only the most recent commit matters here. Rebase your work against current master :)