Updated tests & code to fix a bug