support passing env and custom options to spawn
Merge with previous changes