INAL but even if you did not get paid does not automatically means the result of work for hire belongs to you. If you are a contractor this is a smart thing to explicitly stipulate in the contract.
We don't negotiate on that clause, even under threat of losing very large contracts. IP ownership is the only real leverage contract developers have to get paid.