added tests and refactored cleaning methods a bit