Added test for Entity and fixes inconsistency in id field handling

Change-Id: I1d371ff484db5a86d183a99d8488987cea96b0ba