Implemented check and error message for invalid collection creation and updates, added test for users, refactored server.js code.

Implemented check and error message for invalid collection creation and updates, added test for users, refactored server.js code.