added debug statements, fixed test