Fix Windows path separator issue in `baseFileName`.

Windows accepts forward and backward slashes as path separator.

This fix changes `helpers.baseFileName` to expect a flag (instead of the actual path separator) and then use either `/` (default) or both `\\` and `/`.

This closes #2857 (and #2866).