written unit-tests and followed jshint-tips