Stylistic changes; added several unit tests