Draft fix and test case for formulas like Mg3(PO4)2.