Logging fixes and tests.