Various fixes for headless testing.