fixing and refactoring server functions
remove useless files
add some tests, changes due to server refactoring