update divide using binary search and add unit tests