improved js interface and added tests for it