Replacement for @raoulb pr#914

See #914

ToDo:
- [x] tests
- [x] final rebase
I think we usually have no newline at the end of a docstring, do we?