Fix when scan sequences are provided as a 1-key dict

Add test for that case
Declare variable before using it
Simplify optimization and remove unreachable code.

After additional checks introduced in gh-1578, some code that was
potentially problematic became unreachable. This commit removes it.
This makes gh-1345 obsolete.
Address the case where sequences are provided as dicts.
Merge pull request #1605 from lamblin/scan_minor

Various small fixes in scan