added tests in encode.t