Add unit tests and new functions