test/run_input, ...: add struct ScopeIOThread

Auto-stop the IO thread in all error handlers.
StoragePlugin: pass EventLoop to constructor