Add init() tests before shell injection.
Refactor the attach click handler code.

Moved it to the Shell prototype and added the appropriate tests.