Modular inverse implemented and tested.