simplifyFractions rules work around pi and i

Fixes numbas/editor#165

Things like (a*pi^n)/(b*pi^m) now have the gcd of a and b cancelled out.
Fractions a*i/b*i go to a/b
etc.

A few fixes to the bracketing rules with imaginary numbers and multiples of pi.
Merge branch 'master' of github.com:numbas/Numbas