Adds more logging and asserts so that tests will fail faster and give better error messages.