Fix require() parent directory traversal

This changes some of the require traversal logic to fix #276. Leaves the misleading log discussed in #278 but does also fix up a related code path.

Test result on master before patch:
total ............................................... 861/874

With patch:
total ............................................... 863/876

I've been wondering if it was possible to have the implied inclusion of this function (and ideally an entire suite of test tools), so it doesn't have to be copy/pasted into every file...