Cache join clause in join resolver

1. Caching the computed join clause so that join chain is not reversed in each call
2. In tests doing a list comparison instead of the set comparison earlier