Fix LDC bug, add more unittests