Add tests for Log and fix several problems.