Generalized js wrapper simplification rebased

This is a rebased version of PR #2. Also reused run-brackets.sh to run tests