Add Mpz::{to_i64,to_u64} and Mpq::{rem,fmt}

Also fix Mpz::rem() division by zero check.

Also add tests for added features.