Refactor the tests

Change-Id: Ia0ef3a7a550650b407d8b5acfa1f917311eb3dec