test handler "finished", global error code table added, all functions implement callback with error code
moved most of code into lib folder