just another save
Added some unit tests so that i can refract the encodeFromStream code as it's fucking horrid.