select_nbranches, included unit tests