Introduce NearbyApi to make nearby code more generic and reusable

Add some more tests

Change-Id: I5bf213346dba14a633cad2b2ebd1dbe15bc64a12
Merge "Introduce NearbyApi to make nearby code more generic and reusable"