Refactored tests of declarations so it can be reused for @at locations