(examine_cd): split in two functions to be unit test friendly.