Fix unit tests which failed under pypy due to a change in the way tracebacks were reported.
Make text_content more explicit about the types that it accepts.