Add entity initialize test and fix a bug