Your description points to a suspicion of the condition called as varicocele. This is dilatation of the veins of the testes (stagnation of the blood in the veins of testes). With the lying down, this stagnation disappears. This can give mild pain in the testes. Though erection problem is more likely due to psychological affection of this area which plays on the mind. Please read about the varicocele in this authentic resource;
The other possibility for your symptoms would be epididymis infection called as epididymitis. Epididymis stores sperms after they are formed in testes. A urine culture and a semen culture would be diagnostic for establishment of it's infection. A culture also tells about the best antibiotic to treat this infection.
Please feel free for your follow up questions.
This is not serious and there is no urgency in it. You can get a routine appointment in a week or so.
It is pleasure and privilege assisting you.