Implemented setPolarity
Fixed setPolarity definition and added defines for polarity constants
Implemented setState
Implemented setState and defines
Updated test code