Shared isValid
Altered toArray to array setter and getter
Added some type checks
Modified tests to reflect changes