Add LogSegmentTest.
Fix bug discovered by LogSegmentTest.
Add LogTest.