Refactor rpec tests