Broke out decodings into their own functions; added tests for invalid encoded data