Factor out the code for testing whether a function accesses