Added test and cleaned up code formatting