Calculator: improve exponent handling

Fixes issue #502 and #505

I have added a number of test cases which show arbitrary levels of nested exponents, but I am sure I am missing something.

@jagtalon Could you poke at this with some of your jazzed-up nested expressions and see where it falls down? Please don't look too carefully at the code itself, unless you are hoping to go blind or crazy. I will refactor it when I have gained some perspective (and hopefully failing test cases)
No need to escape the period for the regexp?