DRY up mapping, add tests and coffeelint