Fixed #48.

- Fixed js and C code.
- Added two test cases to spec.