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)
Nope, hooray!  While looking for something else, I discovered info about [quotemeta](http://perldoc.perl.org/functions/quotemeta.html) which let me get away from that.