remove duplication and push all tests into one loop