fixes/cleanup and added tests