finish unit tests and fix bugs
add perf test