add createSubFolders option

And added unit tests for the functionality