Also cleaned up label escaping and consolidated the test suite regarding label_tag. Backport of ab686022f from master.