added testcase and propper encoding