Refactored code to include inject method and specs to include a let