Fix empty directory case, add test for it, and tweak another test