Tests and fix for class toggling

Can we add a test for attempting to toggle a class when there is no selection? That's broken, previously.