fdo#76470: Write unit test for this first.

Change-Id: Iaf609b509165405c1a471dd8556c30dc019922da
fdo#76470: Avoid joining new formula cells individually.

Instead, insert the formula cells in the group first, then only try to join
the top and bottom cells afterward. Otherwise the grouping would get messed
up and a problem would ensue.

Change-Id: I4fdd5326c029032a636d8225b5fb16cbde427c7d