Refactors to use jQuery promises
Working on tests (WIP)