Initial version with complete unit tests.

Signed-off-by: Fridtjof Ahlswede <to.7droids@gmail.com>