add createSubFolders option

And added unit tests for the functionality
Fixes #154
Could you move this test just after the call to `prepareFileAttrs` ? That way, you won't have to check if `o` is here.