Fix duplicate id issue in test and test more corner cases

Change-Id: I4bacfe7353968df7b0f1a8786ae4e488dffa3565