More fixes for tests and code