Remove code duplication to run test commands