Fix branches types in tests
branch names and targets are expected to be bytes. This should allow to get rid of the type castings in check_snapshot().
Also inclde a small code improvement in package/loader.py
Migrated from D3494 (view on Phabricator)