Add support to time out long running queries

Can more of this cut&paste code be refactored so I can see more clearly how these tests are different?