Added directories to valid paths for require()

Fix #245 and #240
Modules contained in directories are skipped so just added checking for directory also.