added several more tests, and fixed a corner case of scan