fix issue with range writer and added more tests