fixed the monte carlo bug, added more tests