Use clean/require in file._check_directory state, Fix #4777

Actually check for file removal if test=True
Handle `clean` logic even if `recurse` is not set
Merge pull request #5014 from basepi/checkdir4777

Use clean/require in file._check_directory state, Fix #4777