Refactor the way gems are loaded for tests to make things more flexible