Fix regression in debug build & test cases
Fix regression in debug build & test cases

[Problem] index going out of bounds
[Cause] using wrong method
[Solution] correct algorithm

Change-Id: I2cd31458534fa8886b7ff27e711fe65e161a1b50

dalihub/dali-core,pwisbey/dali-core,dalihub/dali-core,dalihub/dali-core,pwisbey/dali-core,pwisbey/dali-core,pwisbey/dali-core,dalihub/dali-core