Added unittesting for enconde method