Fixed failing tests and refactored logging