added basic util tests
updated doc string
changed to using mkstemp
removed nested function