Implement extended doctests

This works. But I'm not entirely happy with this approach.

I had to split the logic of `test_content` into two cases: when there is an exception and when there is none. The reason for this is that we need different `rescue` clauses for those cases.

Please take a look @josevalim, @yrashk.

TODO
- [x] clean up `FIXME`s in the code
- [x] mention extended doctests in the docs
- [x] verify that error messages are not broken for extended doctests