Move sample code to test.js
Some error handling for when Pulse is gone.