refactored tests, added tests, refactored logic for diagonal clear