Added tests on prepend/append. Fixed some minor semaphore-related stuff