More test fixes, and some real main fixes to go with those