#3145: refactored infix formatter to improve output (less parenthesis) and added unit tests to test that the infix formatter works correclty.