fixed an NPE bug in ToStringPipe and added TestCase.