handleroute method exported to library and added tests