Refactored and updated tests accordingly
refactored, added exports for client-side validation, updated tests.