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