add qunit testing and refactor pattern definition structure