mumov4xxx, I was given a JRT pup a few weeks before I gave birth. The house I was due to move into was broken into a few days before I moved. My mum panicked and asked the local police what would be the best thing to deter repeat break ins. Police advised that dogs are the best deterrent, not large, guarding breeds, but noisy dogs, cue me being gifted an 8wo old JRT pup two weeks before giving birth 
It was hard but do-able but and it is a big but, I had lots of experience with dogs and a very doggy family to fall on for back up.
In your position I would seek the advise of a professional dog trainer, who uses positive training methods, avoid anyone who talks of pack theory.
Start adjusting routines now to one you think you will be able to cope with with a newborn. Could you afford a dog walker for the first few months?
If the dog will need to start sleeping in a different room, do that now. Bring out baby stuff now and teach the dog to ignore it, using positive, reward based training.
Set the dog up a den/crate in a quiet area of the house so he can escape the chaos of a new baby when he wants to. Teach all children to stay well away from the den/crate. Hide treats and special toys in there to encourage the dog to see it as a good place to be. Put the dog here and make him secure by closing the crate/door when you need to do things that would not allow supervising the dog.
Never leave the dog and baby unsupervised. Ever. Not even for a second. Not even if you think the baby is out of the dogs reach in a pram/moses basket/whatever. Teach the dog to follow you around the house by calling him when you leave and giving him a treat when you get to the next room.
Make sure the dog still gets enough attention, exercise and training after the baby is born. My Dad walked mine for me for the first few weeks with his own dogs and she came everywhere with me, ensuring she was well excerised and socialised.
JRTs are quite feisty but very smart little dogs, at 4 months training should be well under way, what is it you are still struggling with? They're a working breed, high energy with a good hunting instinct, if you don't give them a job and enough physical exercise, they will find their own job and it won't be one you are pleased with, the most common issues being barking and "killing" clothes/teddies/beds/everything and anything. A regular obedience or puppy class with "homework" would help keep his little mind busy and keep him out of trouble or work your way through a good training guide, Jean Donaldson How to Train Your Dog Like a Pro, would be a good start as would Pamela Dennison's Idiots Guide to Positive Dog Training (which covers basics like toilet training and lead walking)
My JRT loved dd1 and was always very gentle with her and naturally protective of her, but that was luck as much as anything else, the JRT X I have now does not like any children other than dd2, he will tolerate them as long as they don't invade his space, but he does not actively like them.