abstract js from html and add test

abstract js from html and add test