reformatted code and fixed test