Add logging and update tests.

The tests were totally wrong and passing for the wrong reasons.