Refine agreement contact queries and organize test data in contacts api.