Added prototypes (see comments for details), streamlined test file