Fix LabelVisualizer crash

#2223 introduced a regression (due to a typo) that was not covered by any unit tests. (which @shunter promptly ran into).  This change adds unit tests and fixed the bug.