Fixed issue with pow grad function trying to evalutate log at 0. Issue 1780
Added unit test.
Note: issue still occurs in debugmode.