Fix for #7761, a second attempt

This PR implements a first suggestion by @smichr, see [this](https://github.com/sympy/sympy/pull/7764#issuecomment-50144169).

Everything seems ok, except for a little cryptic failure in test_trigsimp1 (similar test with tan instead of tanh - works).

Fixes #7761.