Wrote js test and fixed a encapsulation issue