Fix bug and added a quick test