Refactor to eliminate repetition in title test