Add tests with additional clean up

This is a cleaner attempt at the closed https://github.com/turn/ttorrent/pull/58 in a new pull request to avoid losing more comment history.

This includes the tests from #46, cleaned up to minimize unnecessary changes to existing code, and reformat the test code to match existing project code style.