Refactored spec to include context fuction