Added unit tests, fixed bugs in Util.cs code.