Added unit tests, modified some minor things stylistically