added a bunch of unit tests. Also, centralized primitive parsing in an utility class