Serena Williams came through a tough test to clinch a 6-4 4-6 6-4 victory over Caroline Garcia in the third round of the Sony Open Tennis.