fix bug reported by Nicolas

The problem was that the new version of compute_gradient does not return None for a disconnected gradient anymore, but it raises a DisconnectedError. I've changed the code to catch that error and replace it with None, so the rest of the logic in scan_op.grad works as it used to. 

I've added a test (the sample send by Nicolas).