better refactor and make tests run faster