Backport EntityHandlerTest changes from 7645915b31

Change-Id: Iafefc9627bd22a9a656549ee511276a6d923e013