Split up the extension adding and path prepending closures.

This makes it easier to reason about these closures.
Fix bug with non-atom windows commands without extension.

For Windows, the extensions should be tried regardless of whether the
path to the command is given or not.