Various test fixes and improvements