Adds a spawn function and accompanying tests.