Duminy pulls Proteas out of doldrums