refactor and add test for google API wrapper