added tests, updated to work in nodejs and moved functionality from the .done() method to the base object