Fixed compatibility. tests and bugs

Fixed compatibility with stable node version, unit tests and fixed bugs.