Improve DocTest indentation handling

Closes #1350.