Changes for pull request #222, but this causes changes to the doc tests and to the doc examples that still needs to be fixed.
Updating test case for #220