bug 4245 fix with minimum changes

Signed-off-by: Sampath Liyanage <plbsam@gmail.com>
unit tests updated. Some global variables were set in setup functions of some test files. one testing function with mockobjects was changed from once() to exactly(2) because the bug fix has made that function calls twice

Signed-off-by: Sampath Liyanage <plbsam@gmail.com>
Merge pull request #878 from sampathLiyanage/bugfix4245

Bug fix (#4245) - initial "Browse" query does not match sorting order