Refactor off-site checks into shared code

Also add more tests.