Added unit tests to repo; Some minor bug fixes in unit testing.