adds test for encode
encode function passes test