Dimension: fixed some bugs and implemented unit test (close #24)