started work on Decode function and tests for it