Benin and Sudan qualified for the Africa Cup of Nations, but heavyweights Ghana, Nigeria and Tunisia suffered embarrassing home defeats on the penultimate day of preliminaries for the finals.