refactor using shared_examples pattern