Add error handling if attach() is not given a function (closure)
Added more samples
Enable unit test to be run via npm test
Minor: rename construct() to instantiate()