codecleaning and add some tests