This phase I trial is studying the side effects and best dose of decitabine and valproic acid in treating patients with refractory or relapsed acute myeloid leukemia or previously treated chronic lymphocytic leukemia or small lymphocytic leukemia. Drugs used in chemotherapy, such as decitabine, work in different ways to stop cancer cells from dividing so they stop growing or die. Valproic acid may stop the growth of cancer cells by blocking the enzymes necessary for their growth. Combining decitabine with valproic acid may kill more cancer cells.