Bug fix and test extended