update tests and lib fns to pass unit tests