Added "connected" event

Also added astests.js to simply test the new functionality / bugs of
adminscript.