Scan command, fixes tests and restores ruby<1.9 compatibility