Add related_manager support for Queries, updated tests