Added tests... and found bugs!