Added unit test for entity encoding