Improve test runner

The test runner was not reporting errors correctly.
The error code wasn't being propagated.