Fix bug in unsigned modular arithmetic using a signed implementation