Add tests for vars w/ trailing spaces, outputs containing spaces

This adds the tests for the change in e400f313.

This change also fixes a bug where ctrl-c'ing out of the build might not
clean up the thread pool properly.