Extracted 'spawn_command' into its own action module

Moved spawnCommand into its own module and made the tests a lot DRYer.