South Africa on top in Cape Town despite fighting Kohli fifty