Fix tests and test infrastructure