tor: Clean up control command API

A lot of this API is really ugly. This makes it slightly less ugly.
Data replies are also handled correctly now, and error handling is
improved.