added test before deleting non-empty directories