Add timeout feature, extra testing, and cache_cas checks.

Sorry, should have broken this into a couple of separate commits. Let me know if you only want some of it.