factor out duplicated test command code