fix rspec warning problem and add login function