fix error on dirs and non-files via stat check

Mainly just switches from `fs.stat().isFile()` instead of `fs.exists`.
Added a sync test and an async test.