Refactor and adapt tests to work with real api #2975