add lib and some tests, modify setup