```coffeescript
{expect} = require "chai"
utils = require "../utils"

{Collections} = utils.require "common/base"

describe "categorical mapper", ->
  mapper = null
  before ->
    mapper = Collections('CategoricalMapper').create(
      source_range: Collections('FactorRange').create
        factors: ['foo', 'bar', 'baz']
      target_range: Collections('Range1d').create
        start: 20, 'end': 80
    )

  it "should map first category to bottom third", ->
    expect(mapper.map_to_target "foo").to.equal 30

  it "should map second category to middle", ->
    expect(mapper.map_to_target "bar").to.equal 50

  it "should map third category to upper third", ->
    expect(mapper.map_to_target "baz").to.equal 70
```

Refactor test case around to use a test method for each test
user
```coffeescript
{expect} = require "chai"
utils = require "../utils"

{Collections} = utils.require "common/base"

describe "categorical mapper", ->
  factors = ["foo", "bar", "baz"]
  start = 20
  end = 80

  testMapping = (key, expected) ->
    mapper = Collections("CategoricalMapper").create
      source_range: Collections("FactorRange").create factors: factors
      target_range: Collections("Range1d").create start: start, end: end
    expect(mapper.map_to_target key).to.equal expected

  it "should map first category to bottom third", ->
    testMapping "foo", 30

  it "should map second category to middle", ->
    testMapping "bar", 50

  it "should map third category to upper third", ->
    testMapping "baz", 70
```
assistant