Toggle: fix unit test checking className attribute

Makes sure the element has a className attribute before
attempting indexOf call.