Fixed encoding and got all unit and integration tests passing.