Fixed the failing repository tests

Please review it
thanks
Again, this code is incorrect. See earlier comment.