Add some tests and fixes for Promises.