Removes duplicate code from tests