Closes #1921. Adds unit tests for the legend.