Misc fixes

I've made a few fixes now. I know you're working on time-based tests but I wondered whether it would be useful to have these fixes in mainline in the meantime.