Fix unit tests, refactor out logging proxy creation, slightly improved error handling.

Hunter please review and merge this when you get a chance.