formatted code and added test