Add tests for build_sets; clarify comments