Fix incorrect values returned by binary_to_integer/2

When `binary_to_integer/2` receives 0 or a negative number as an argument
with a base that is different from 10, it will return incorrect values
(`<<>>` in the case of 0) or it will crash (with negative numbers). This
commit fixes these problems and adds tests to cover these cases.