Fix bugs related to message parsing and add missing timeout

Signed-off-by: Krzysztof Opasiak <ups100@tlen.pl>