fix replace method
add ability to specify api prefix
fix failing tests