improve custom line creation

reason: selecting the first context may be a bad idea (e.g. context
with inexisting entity)