Correcting decoding and adding tests