add some tests and reorganize