MODE-1974 Corrected RepositoryStatistics

Made several corrections and improvements to the RepositoryStatistics functionality, though most of the changes are for tests. Verified the fix by running a test for 65 minutes (this test method is @Ingore'd and will not run during any of the builds) and getting the same windows as reported in the issue.

These changes should be merged onto the 'master' branch and cherry-picked onto the '3.3.x' branch.