Added tests and applied PR comments.