Do you really expect your slumlord to give you your security deposit back? You'll probably have to sue him. But you'll lose if you don't follow the landlord tenant laws.

Read them at:

http://law.justia.com/codes/new-york...rpp/article-7/

As for a Certificate of Occupancy, I think you are dreaming if you think he will cooperate about that. I suggest you call the city building department, report your suspicions, and ask for an inspection to determine if the apartment is legal. If it's not legal, the city inspector will order you to leave and then you can sue the landlord for the security deposit and rent refund.