Update debug statements to use logger, and add test.