Fully working with tests. Just needs to be tidied and documented now.