introduce inverse_modulo function
add more invariants
commit intermediate state