This starts out with the priest demanding that Joseph 'give back' Mary.
Oh, let's take a moment and, as women, be insulted by that. Done? Me neither. Take another moment and remember that this is 2,000 years ago. It helps me anyway. :)
Joseph weeps and the priest declares that he will give Joseph the 'water of the Lord's rebuke to drink' and it will make his sin apparent to him. The 'water of the Lord's rebuke' is mentioned in Numbers 5:11-31 - if a 'spirit of jealousy' causes a man to think that his wife has cheated on him he can take her to the temple and the priest will give her a drink that consists of water mixed with dust from the temple floor. (For the record, EWWWWWWWW. *makes icky face*) If she drinks this and convulses in agonising pain, she's guilty. If she has no reaction, she's innocent. Um. Well, it has the weight of likely saving a good deal of marriages. Aside from that it seems to be a fairly silly and useless test of innocence. Ah, historical methods of 'truth finding' you are either really amusing or totally deadly.
Joseph takes the 'truth serum' and drinks it. Nothing happens. So the priest gives it to Mary. She drinks and is sent out into the hill-country. Why? It doesn't say anything about Joseph being sent out to the hill-country or anywhere else when he's given the 'truth serum', so why send Mary out? I have no explanation. It just strikes me as odd, really. Mary comes back unharmed and everyone is shocked that no sin was found in either Joseph or Mary.
The priest says, "If the Lord God does not reveal your sin, then neither will I condemn you." So Joseph takes Mary and return to his home, rejoicing and glorifying God.