Refactor test with shared_examples