implement encode to decode test
fix bug for longer content