Refactor repository watching behaviour into its own class, and test it