added addentity test and implemented necessary fixes to make it work