Tests and fix for class toggling