Scan command, fixes tests and restores ruby<1.9 compatibility

Addition to #376