changed to match coding style, added test case for error in completionFunction