fix parsing of hex numbers and add tests for it