Fix for branch / repos. Add tests
More fixes