Properly detect missing directories
Add test case for empty directory