Proper decimal encode/decode

Various encoding bug fixes.
Adds additional tests for varint and decimal.