corrected implementation and TestSM2