Reimplement line.insertText() and add tests

Bunch of other impelementations changed due to this (helpers changed
thus also functions relying on helpers)