Fixed multi-shell handling.

Last merge was about shell connecting to more daemon simultaneously, while this merge is about daemon correctly handling different shells. And tests output works too (almost, check email for details).