Added tests. Minor cleanup.