Such a test is done in several places in the codebase, sometimes incorrectly. Makes sense to centralise it.