Tests and fix for class toggling

This now works as expected.