Refactored code for repository testing.
Added random unit tests for tori.db.repository.Repository.