Added unit tests, improved splicing algorithm