Fixing bug in Repository when changing context