Handle empty dirs
Refactor tests for brevity