Added some unit test coverage.
Fixed test output capture when the test output does not end with a line separator.