firs implementation and tests