added tests and refactored source code to be jquery plugin compliant