Fix broken spec
Make external api to a factory function