Fixed getting existing build numbers from db
Always sort build numbers correctly

In case there are test cases that do not have all build numbers the
uniq will not produce ordered build numbers list.