added more test, fixed bug in core