Tests and fix for class toggling

The reason that we use `last()` instead of first might be worth including in a docstring for `parentsOrSelf`. That behavior is very surprising to me.