Added tests & bug fix.