Added code and tests for valid and constructor