pass unit tests (by fixing promise scoping, other miscellany)