some bug fix and test. updated TODO
Signed-off-by:Sergio L. <mellowonpsx@gmail.com>