formatted code and added unit tests