Fix incorrect values returned by integer_to_binary/2

When `integer_to_binary/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.