Fix a Django 1.6 TreeEditor bug
Simplify code.
Rework shorten_string, which had pathological behaviour if no space could be found near the wanted splitting point.
Add tests for it too.