Extract functions out to jquery block.
Add unit test.