Add some unit test, refactor the code of nameserver, add lock support.