[tor-commits] [tor/master] refactor and give it unit tests