Fix BigInteger mod function and improve GCD tests, among other things