Simplify associative terms. Add test cases.