fixed bugs in entity and wrote a nonfunctional test main function