Fixes #633

@lamblin . Unit tests to be added.
Why cast as int64? It does not really make sense, as it will be 0 most of the time, and we want to test a wide range of values.