test code factorized

Change-Id: Iefdfdd808cfc476faaec8b6e343b7636d7720c6f