Refactor tests to be dry