Fixed printing of contractions with multiple coefficients and added test cases.