Move `isEmptyDir` to the command utilities.

Removes duplicated test helper.