refactor to make the code a bit DRYer

- add initOptiions method, to have single place for settings defaults and create options object if neccesary
- add testRange method to have single place to throw range errors
- add constance for max and min integer
- remove unused options parameter in some methods
- add missing `var` statement