Use safe_new(x) instead of x.type() in scan grad.

This copies the test_value, making possible to use a test value
for sequences. Add test.

NEWS.txt: fix crash when trying to use compute_test_value for a non_sequence when calling the gradient of scan (reported by Bitton Tenessi).