debug, tidy and test