Added a method to decode a stream
Added tests