Fix bug from old code and bad testing