Fixed a bug in factorizing division of exponentiation nodes.
Added tests for factorization.