Refactor for getDownloadCandidates with unit tests.