(Standard disclaimer - I'm not a lawyer...)
From your profile you appear to be in the UK.
In that instance it depends on how you're employed. If you're a permanent member of staff then almost certainly your employer owns the works. You wrote them and have the rights to be identified as the author (that is you can tell people that you wrote them) but the ownership of the code and the intellectual property therein resides with your company.
If you're a contractor then there might be a case that you have some claim to them but it would depend on the nature of the contract. Generally speaking most UK IT contractors are classed as workers for hire which means that again the IP rests with the company rather than the individual. Certainly talk of a standard employment contract suggests that this will be the case whether you be permanent of contract.
Under these circumstances you have no right to release them as open source (or indeed to take them on to your next employer) and you should think about them in the same way you think about any other piece of proprietary software and act accordingly - they're not yours, you just happen to have access to the source code.
EDIT: Regarding the fact that you developed some of it in your own time. The minute you started using it at work without asserting your rights and licensing it to the company in advance you made it very murky as it's now very hard to show what was done when. From what you're saying the code libraries have been tested, debugged and fixed in work time (and the company owns anything done in their time), plus the obvious overlap with work you were doing for them (as evidenced by the fact that they fulfilled a requirement the company had which you were working on) means that they do have a claim and probably a pretty strong one.
The Unite Union has a piece on this. The key section appears to be:
"There are express statutory provisions:
· Section 11 (2) of the Copyright, Designs, and Patents Act (CDPA) 1988 and
· Section 39 of the Patents Act 1977
dealing with ownership of employee works. Under these provisions, employers essentially gain ownership of intellectual property rights in respect of any works created by an employee which he/she
· was required to produce under the terms of their employment contract or
· could reasonably be expected to produce under the terms of that contract.
Obviously, the wider the job description of the individual employee, the more difficult it will be for him/her to avoid the effects of Sections 11(2) and 39 above.
Even if the work is created by the employee in their own time and using their own resources, the employee will not necessarily be able to claim any rights in that work, if the employer shows that the nature of the work created was that which could be reasonably contemplated as part of the employee’s duties. This is demonstrated by the case of Missing Link Software v Magee [1989]FSR 361. There, the court held that copyright in a software programme written by an employee outside his work time and on his own equipment was made in the course of employment, as it fell within the scope of the tasks that Mr Magee was employed to carry out."
Basically because these libraries met a specific requirement on a project that you were working on for them, they have a claim on them.
EDIT 2: You need to understand that the fact that there are two versions of the code is probably irrelevant. The code meets a need the company has on a project you were working on and you wrote it while employed by the company (even if it was in your own time). That gives them a strong claim on the "core IP" of the code, not just on a specific copy of it you happened to implement on their project - viewing it as two branches doesn't change that.
It's worth noting that even rewriting it would be termed a derivative work and the IP would still sit with the company, even on a new version.
I think you have an idea of what you want to be true and you're trying to twist things to make that so but from what you're saying I believe the company has pretty strong claim to the code that you're not going to be able to work around.