Fixed spawnChild and added tests.

Fixed spawnChild and added tests.