Move all ProgramEntry validation checking prior to db insertion into
ProgramEntry.

Also update tests with this change. This included the addition of a new
tests file to test ProgramEntry directly rather than in a roundabout way
through the API tests. This resulted in cleaner tests and cleaner code
that fails faster. It also eliminated the need for a couple complicated
API tests.