Changed to Coffeescript, added tests