Pass exitCode by reference

Arguments to defer statements are evaluated when the defer statement is
evaluated, so pass exitCode by reference instead.

Fixes issue #346
It would be more idiomatic to have this be `testHandleRemoteExec`