Fixing bugs and adding additional test.