range tests and refactor