Corectness fix, selftest added.