Tests and fix for class toggling

New tests for class toggling. We had none.