Fix js func issue, fix tests