binary_search implementation, and tests