Expose js api, add tests