Refactor code to prepare for parallel tests am: 2aaa3f84b3 am: 699747fbf7

Change-Id: I38c38fed456634478a2d31dfa68a43d300ba13d4