fix login for contractor and add unit tests