Refactor mock rest client and connection into class

Change-Id: Ie24f9664342dc99148d36fd7da73c8a7cb55ceca