some refactorings,
added missing properties,
fixed missing user id in registration,
checked some preconditions
added tests for branch coverage