minor optimization && improve tests