Added smallint support.

Also fixed some bad logic in the decode function.
Added decodeint.

Also moved all tests into testcase wrappers.