fixes invert
adds test of combining like terms