added autocomplete function source from db, cleaned up code, rewrote tests