Fix module subdirectory resolution

Includes test case

Node.js' test cases aren't comprehensive enough.