Logging and better null handling for tests