Refactor log module. Added log test.