Unit tests and refactor

Working on adding unit tests and getting a good test coverage.

On the way, I'm trying to unify some duplicate code especially related to launching btcd/btcwallet and connecting rpc client.
Minor nit but I don't think this newline belongs here (all of the imports are part of the stdlib).  Curious if you use goimports and it added it.