Moving test code to library