Fixed bug in BlockManager and added a testcase