Updated logging. Added test.