Added decode functionality and basic tests