changes to use code as a library
repair tests