[QA] Extract quarantine code into a module and add tests
@sliaquat started a discussion in !24942 (merged) that revealed a lack of coverage of the quarantine test feature. Trying to implement that coverage showed that using RSpec to test parts of RSpec isn't simple, but RSpec's own unit tests provide what's needed.