resolved the mentioned bug and added tests