add some code and unittests

Signed-off-by: Andras Mitzki <micek@balabit.hu>