Respond to code review of unit test for tempfile

This commit modifies the code according to some suggestions provided in
a code review of the previous commit, plus some new thoughts of mine.

Reduce the dependency on the nvim os module by reimplementing is_dir() using lfs.attributes().
Simplify implementation of is_empty().
Convert some assertions from using ok()/notok() to using eq()/neq().
Convert remaining notok(predicate) assertions and to ok(not predicate) assertions.
Initialize all local variables while declaring them.

Provide one-line comments for some functions.
Reduce the scope of some locals.