Trailing text was lost in processing. Also add tests to check this behavior plus some basics. fixes #3382