Fixed bug and updated tests