Add integer encoding and tests