Preparing for unit testing; updated comments and contracts