Reduce the number of places that create empty text nodes

Empty text nodes are never deliberately left behind after an operation. This patch adds some checks to the operations test to help prevent more of these, and cleans up the primary creator of empty text nodes.