The variable sm should contain the signature and the message, not the message and the signature (i.e. the order is crucial).
This makes it easier to mix and match with other implementations for compatibility testing.