Fix scanner and add more tests