Issue 77 trimtext misbehaving

Should fix issue #77 (also see the unit tests which cases are handled correctly)