Some code refactoring in dungeon.py and test cases added.