repetitive code fixed on tests