Added validation to the model and moved the JS to the correct file.
Added unit tests for the code.