Tests and fix for class toggling

`toggleClass` was broken as it toggled the class to all matched ancestors.