Refactor and doc configure, fix testnet unit tests, fix osx build.