refac code so tests runs