Fixed prepend and append issues, added more unit tests