Complete the functions and tests about login and logout.