Fix invmode

little inversion, with fixed testS.