Add test cases for Rest API, fix search not returning intersection

More test cases for #16, fix for #15