Fix-crash in scan grad when compute_test_value=raise

fix gh-1385
Add test.
Merge pull request #22 from lamblin/fix_crash

Add test
Merge pull request #1388 from nouiz/fix_crash

Fix-crash in scan grad when compute_test_value=raise