torrent state implementation and tests
torrent state implementation and tests