add class only if doesn't exist
added test
Change state definition to more readable
Merge pull request #505 from 0xBADC0FFEE/toggle-class

toggleClass: add class only if doesn't exist