required user sign in, some refactor and test