Properly handle Long-like object in valueOf, fixes #13