Fixed a previous bug, and added more tests