fixed segmentation fault+some tests