Refactor tests to make them more efficient