Corrected a serious bug + more tests