Refactor common elements in object tests