added test, put peer id generation in function